﻿@model IEnumerable<mesoBoard.Data.Message>
@{
    Layout = "~/Views/Shared/_User.cshtml";
}

<div class="messages_inbox messages_sent section">
    <h2>Sentbox</h2>
            
    <table>
        <tr>
            <th class="from">From</th>
            <th class="subject">Subject</th>
            <th>Message</th>
            <th class="date">Date</th>
        </tr>

        @{  int i = 0;
            foreach (var msg in Model)
            { 
                <tr class="message @(i++ % 2 == 0 ? "bg_color2" : "bg_color3")">
                    <td>
                        @Html.ActionLink(msg.ToUserID.HasValue ? msg.ToUser.Username : "User Deleted", "ViewMessage", new { MessageID = msg.MessageID })
                    </td>
                    <td>
                        @Html.ActionLink(msg.Subject.Shorten(18), "ViewMessage", new { MessageID = msg.MessageID }) 
                    </td>
                    <td>
                        @Html.ActionLink(msg.Text.Shorten(40), "ViewMessage", new { MessageID = msg.MessageID }) 
                    </td>
                    <td>
                        @Html.RelativeDate(msg.DateSent) 
                    </td>
                </tr>
            } }
        @if (Model.Count() == 0)
        { 
            <tr><td colspan="4" align="center">No sent messages</td></tr>
        } 
    </table>

    @Html.Partial("_Pagination", ViewData["Pagination"])
</div>


